package com.itjoyee.redis.benchmark.jedis;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.itjoyee.redis.benchmark.base.Bench;
import com.itjoyee.redis.benchmark.base.Benchmark;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * 
 */
public class MapFastPutBenchmark {

    public static void main(String[] args) throws InterruptedException {
        Bench<JedisPool> bench = new JedisBench() {
            @Override
            public void executeOperation(String data, JedisPool benchInstance, int threadNumber, int iteration,
                    MetricRegistry metrics) {
                Jedis jedis = benchInstance.getResource();

                Timer.Context time = metrics.timer("map").time();
                jedis.hset("map_" + threadNumber, data, data);
                time.stop();

                jedis.close();
            }
        };
        
        Benchmark benchmark = new Benchmark(bench);
        benchmark.run(args);
    }
    
}
